import {
  Table,
  Row,
  Col,
  Form,
  Input,
  Icon,
  InputNumber,
  Radio,
  DatePicker,
  Select,
  Upload,
  Button,
  Switch,
  Modal,
  Popconfirm,
  Tabs,
  message,
  Steps,
  Card,
  Tag,
} from 'antd';

import { FormComponentProps } from 'antd/es/form';
import React from 'react';
import SingleDragger from '../../../../../components/Commons/SingleDragger';
import { connect } from 'dva';
import Constants from '@/utils/Constants';
import Validator from '@/utils/Validator';

const R = require('ramda');
const FormItem = Form.Item;
const RadioGroup = Radio.Group;
class CstForm extends React.PureComponent {
  constructor(props) {
    super(props);
    this.state = {};
  }

  render() {
    const { getFieldDecorator } = this.props.parent.form;
    let disabledStatus =
      R.isEmpty(this.props.disabledStatus) || R.isNil(this.props.disabledStatus)
        ? true
        : this.props.disabledStatus;
    let data = R.isEmpty(this.props.data) || R.isNil(this.props.data) ? {} : this.props.data;

    return (
      <Row gutter={24}>
        <Col span={8}>
          <FormItem label={<span>企业名称(中文)</span>}>
            {getFieldDecorator('companyname', {
              rules: [{ required: true, message: '请填写企业名称(中文)！' }],
              initialValue: data.entepriseName,
            })(<Input placeholder="填写姓名或昵称" disabled={disabledStatus} />)}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>企业名称(英文)</span>}>
            {getFieldDecorator('companynameen', {
              rules: [{ required: true, message: '请填写企业名称(英文)！' }],
              initialValue: data.entepriseNameEn,
            })(<Input placeholder="填写姓名或昵称" disabled={disabledStatus} />)}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>企业简称</span>}>
            {getFieldDecorator('shortname', {
              rules: [{ required: true, message: '请填写企业简称！' }],
              initialValue: data.shortname,
            })(<Input placeholder="填写姓名或昵称" disabled={disabledStatus} />)}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>是否查询企业信用</span>}>
            {getFieldDecorator('ischeckinfo', {
              rules: [{ required: true, message: '请选择是否查询企业信用！' }],
              initialValue: data.ischeckinfo,
            })(
              <RadioGroup disabled={disabledStatus}>
                <Radio value={'1'}>是</Radio>
                <Radio value={'2'}>否</Radio>
              </RadioGroup>,
            )}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>企业类型</span>}>
            {getFieldDecorator('companytype', {
              rules: [{ required: true, message: '请选择企业类型！' }],
              initialValue: data.companyType,
            })(
              <Select style={{ width: '100%' }} disabled={disabledStatus}>
                <Select.Option value="0" key="0">
                  一般纳税人
                </Select.Option>
                <Select.Option value="1" key="1">
                  小规模
                </Select.Option>
                <Select.Option value="2" key="2">
                  境外
                </Select.Option>
                <Select.Option value="3" key="3">
                  个人
                </Select.Option>
              </Select>,
            )}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>经营模式</span>}>
            {getFieldDecorator('businessmodel', {
              rules: [{ required: true, message: '请选择经营模式！' }],
              initialValue: data.businessmodel,
            })(
              <Select style={{ width: '100%' }} disabled={disabledStatus}>
                <Select.Option value={0} key={0}>
                  工贸一体
                </Select.Option>
                <Select.Option value={1} key={1}>
                  贸易型公司
                </Select.Option>
                <Select.Option value={2} key={2}>
                  生产型工厂
                </Select.Option>
              </Select>,
            )}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>移动电话</span>}>
            {getFieldDecorator('mobile', {
              rules: [
                { required: true, message: '请填写移动电话！' },
                { pattern: Validator.mobile, message: '请输入正确的移动电话' },
              ],
              initialValue: data.mobile,
            })(
              <Input
                placeholder="填写姓名或昵称"
                style={{ width: '100%' }}
                disabled={disabledStatus}
              />,
            )}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>固定电话</span>}>
            {getFieldDecorator('telephone', {
              rules: [
                { required: true, message: '请填写固定电话！' },
                { pattern: Validator.phone, message: '请输入正确的固定电话' },
              ],
              initialValue: data.telephone,
            })(
              <Input
                placeholder="填写姓名或昵称"
                style={{ width: '100%' }}
                disabled={disabledStatus}
              />,
            )}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>邮箱（E-mail）</span>}>
            {getFieldDecorator('email', {
              rules: [
                { required: true, message: '请填写邮箱（E-mail）！' },
                { type: 'email', message: '请填写正确的邮箱' },
              ],
              initialValue: data.email,
            })(<Input placeholder="填写姓名或昵称" disabled={disabledStatus} />)}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>传真</span>}>
            {getFieldDecorator('tax', {
              rules: [{ required: false, message: '请填写传真！' }],
              initialValue: data.tax,
            })(<Input placeholder="填写姓名或昵称" disabled={disabledStatus} />)}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>统一信用代码</span>}>
            {getFieldDecorator('taxpayerid', {
              rules: [{ required: true, message: '请填写统一信用代码！' }],
              initialValue: data.taxpayerid,
            })(<Input placeholder="填写统一信用代码" disabled={disabledStatus} />)}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>海关注册登记号码</span>}>
            {getFieldDecorator('customsregno', {
              rules: [{ required: true, message: '请填写海关注册登记号码！' }],
              initialValue: data.customsregno,
            })(<Input placeholder="填写姓名或昵称" disabled={disabledStatus} />)}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>公司地址(中文)</span>}>
            {getFieldDecorator('address', {
              rules: [{ required: true, message: '请填写公司地址(中文)！' }],
              initialValue: data.address,
            })(<Input placeholder="填写姓名或昵称" disabled={disabledStatus} />)}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>公司地址(英文)</span>}>
            {getFieldDecorator('addressen', {
              rules: [{ required: true, message: '请填写公司地址(英文)！' }],
              initialValue: data.addressen,
            })(<Input placeholder="填写姓名或昵称" disabled={disabledStatus} />)}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>收件地址</span>}>
            {getFieldDecorator('recaddress', {
              rules: [{ required: true, message: '请填写收件地址！' }],
              initialValue: data.recaddress,
            })(<Input placeholder="填写姓名或昵称" disabled={disabledStatus} />)}
          </FormItem>
        </Col>
        <Col span={8}>
          <FormItem label={<span>公司网址</span>}>
            {getFieldDecorator('url', {
              rules: [{ required: false, message: '请填写公司网址！' }],
              initialValue: data.url,
            })(<Input placeholder="填写姓名或昵称" disabled={disabledStatus} />)}
          </FormItem>
        </Col>
      </Row>
    );
  }
}

export default CstForm;
